package cn.wolfcode.service.impl;

import cn.wolfcode.domain.Department;
import cn.wolfcode.mapper.DepartmentMapper;
import cn.wolfcode.qo.QueryObject;
import cn.wolfcode.service.IDepartmentService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
@Service
public class DepartmentServiceImpl implements IDepartmentService {
    @Autowired
    private DepartmentMapper departmentMapper;

    @Override
    public void deleteByPrimaryKey(Long id) {
        departmentMapper.deleteByPrimaryKey(id);
    }

    @Override
    public void insert(Department record) {
        departmentMapper.insert(record);

    }

    @Override
    public Department selectByPrimaryKey(Long id) {

        return departmentMapper.selectByPrimaryKey(id);
    }

    @Override
    public List<Department> selectAll() {

        return departmentMapper.selectAll();
    }

    @Override
    public void updateByPrimaryKey(Department record) {
        departmentMapper.updateByPrimaryKey(record);

    }

    @Override
    public PageInfo<Department> query(QueryObject qo) {
        PageHelper.startPage(qo.getCurrentpage(), qo.getPageSize());

        List<Department> departments = departmentMapper.selectForList(qo);
        return new PageInfo<Department>(departments);
    }
}
